//index.js
//获取应用实例
const app = getApp()
const request = require('../../../utils/api.js')
Page({
  data: {
    winWidth: 0,
    winHeight: 0,
    // tab切换  
    currentTab: 0,
    picList:[],
    docList:[],
    pageSize:5,
    pageNum:1,
    type:1

  },
  onLoad:function(){
    this.queryPrintList(this.data.type);
  },
  bindChange(e) {
    var that = this;
    that.setData({ currentTab: e.detail.current });
  },
  swichNav(e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current,
        "type":2
      })
      this.queryPrintList(that.data.type);
    }
  },
  queryPrintList(type) {
    const self = this

    const data = {
      url: '/v3/print/print_record',
      method: 'POST',
      param: {
        'type': type,
        'source': 2,
        'pageNum': 1,
        'pageSize': 10
      }
    }
    request(data).then(res => {
      //console.log(res);
      if (res.data.code === 200) {
        //console.log(res)

        if(type==1){
          this.setData({
            'picList': res.data.data
          })
          console.log(this.data.picList)
        }else{
          this.setData({
            'docList': res.data.data
          })
          console.log(this.data.docList)
        }
      
       
      }
      else if (res.data.code === 401) {
        $Message({
          content: '页面过期',
          type: 'error'
        })
        setTimeout(function () {
          wx.removeStorageSync('isLogin')
          wx.redirectTo({
            url: '../login/login'
          })
        }, app.globalData.loginOutTime)
      }
    })
  },

  //页面触底监听事件
  onReachBottom:function(){
    console.log("是否有这个函数")
  }




})
